import "crvpuppet"

define at3_vmbridge($webaddr="", $roleid="") {
  if $AutoMode==true and $CloudCRV==true {
  }

  if ( $AutoMode == false ) or ( $AutoMode==true and $CloudCRV==true ) {
    
    file { "/etc/sysconfig/network-scripts/ifcfg-eth1":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_vmbridge/ifcfg-eth1.tpl"),
    }
    
    file { "/etc/sysconfig/network-scripts/ifcfg-privatebr":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_vmbridge/ifcfg-privatebr.tpl"),
    }

    exec { enableeth1:
      command => "ifup eth1",
      require => File["/etc/sysconfig/network-scripts/ifcfg-eth1"],
    }

    exec { enableprivatebr:
      command => "ifup privatebr",
      require => [File["/etc/sysconfig/network-scripts/ifcfg-privatebr"], Exec["enableeth1"]],
    }
  }
  
  if $AutoMode==true and $CloudCRV==true {
    #publish some variables, e.g. InteractiveNodePublicAddress and let CloudCRV display it on the front.
    set_role_attr($webaddr,$roleid,"ProfileApplied","True")
  }
}

define at3_vmbridge_reverse($webaddr, $roleid) {
  set_role_attr($webaddr,$roleid,"ReverseProfileApplied","True")
}

